local more1__jushou = fk.CreateSkill{
  name = "more1__jushou",
  tags = { Skill.Compulsory},
}
Fk:loadTranslationTable{
  ["more1__jushou"] = "据守",
  [":more1__jushou"] = "一名角色回合开始时/当你需要使用非延时锦囊牌时，若你的武将牌正面朝上，你可以翻面并视为你使用一张任意/你需要的非延时锦囊牌。"..
  "当你翻面后，你可以选择一项:1.回复一点体力，2.移动场上一张牌。",
  ["more1__jushou_move"] = "移动场上一张牌",
  ["more1__jushou_recover"] = "回复一点体力",
  ["#more1__jushou-move"] = "移动场上一张牌",
  ["#more1__jushou-choice"] = "视为使用一张非延时锦囊牌",
  ["#more1__jushou_choice"] = "视为使用 %arg",
  ["$more1__jushou1"] = "良将如匠，雕朽木为栋，化顽石为铁。",
  ["$more1__jushou2"] = "万卒入伍，练之数旬，余之二三者可称锐。",
}
more1__jushou:addEffect(fk.TurnedOver, {
  anim_type = "control",
  can_trigger = function (self, event, target, player, data)
    return target == player and player:hasSkill(more1__jushou.name) 
  end,
  on_cost = function (self, event, target, player, data)
    local room = player.room
    local choices = {"more1__jushou_recover"}
    if #room:canMoveCardInBoard() > 0 then
      table.insert(choices, 1, "more1__jushou_move")
    end
    local choice = room:askToChoice(player, {
      choices = choices,
      skill_name = more1__jushou.name,
    })
    if #choice > 0 then 
      event:setCostData(self, {choice = choice})
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local choice = event:getCostData(self).choice
    if choice == "more1__jushou_move" then 
      local targets = player.room:askToChooseToMoveCardInBoard(player, { prompt = "#more1__jushou-move", skill_name = more1__jushou.name })
      if #targets == 0 then
        return false
      end
      player.room:askToMoveCardInBoard(player, { target_one = targets[1], target_two = targets[2], skill_name = more1__jushou.name })
    else
      player.room:recover{
        who = player,
        num = 1,
        skillName = more1__jushou.name,
      }
    end
  end,
})

more1__jushou:addEffect("viewas", {
  pattern = ".",
  prompt = function (self, player, selected_cards, selected)
    return "#more1__jushou-choice"
  end,
  interaction = function(self, player)
    local all_names = Fk:getAllCardNames("t")
    local names = player:getViewAsCardNames(more1__jushou.name, all_names)
    if #names == 0 then return end
    return UI.CardNameBox {choices = names, all_choices = all_names}
  end,
  card_filter = Util.FalseFunc,
  view_as = function(self, player, cards)
    if not self.interaction.data then return end
    local card = Fk:cloneCard(self.interaction.data)
    card.skillName = more1__jushou.name
    return card
  end,
  before_use = function(self, player)
    player:turnOver()
  end,
  enabled_at_play = function(self, player)
    return player.faceup
  end,
  enabled_at_response = function(self, player, response)
    return not response and player.faceup
  end,
})

more1__jushou:addEffect(fk.TurnStart, {
  can_trigger = function (self, event, target, player, data)
    return player.faceup and player:hasSkill(more1__jushou.name) 
  end,
  on_cost = function (self, event, target, player, data)
    if player.room:askToSkillInvoke(player, {
      skill_name = more1__jushou.name,
    }) then
      local all_names = Fk:getAllCardNames("t")
      local names = player:getViewAsCardNames(more1__jushou.name, all_names)
      if #names == 0 then return end
      local choice = player.room:askToChoice(player, {
        choices = names,
        skill_name = more1__jushou.name,
        cancelable = true,
      })
      if #choice > 0 then 
        event:setCostData(self, {choice = choice})
        return true
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    player:turnOver()
    local choice = event:getCostData(self).choice
    local use = player.room:askToUseVirtualCard(player, {
      name = choice,
      skill_name = more1__jushou.name,
      prompt = "#more1__jushou_choice:::"..choice,
      cancelable = false,
    })

  end,
})





return more1__jushou